//
//  MorseCode.m
//  HelloIphone
//
//  Created by Geoffrey Gallaway on 2/13/09.
//  Copyright 2009 TDK Technologies. All rights reserved.
//

#import "MorseCode.h"

@implementation MorseCode

@synthesize dit;
@synthesize dah;
@synthesize toneDelay;
@synthesize letterDelay;
@synthesize wordDelay;

-(id)init {
	self = [super init];
	if (self != nil) {
	}
	return self;
	
}
- (void) stringToTonesList:(NSString*)text tones:(NSMutableArray*)tones {
  const char *charas = [text cStringUsingEncoding:NSASCIIStringEncoding];
  int total_charas = strlen(charas);
  for (int i = 0; i < total_charas; i++) {
	  switch (charas[i]) {
		  case ' ':
			  [tones addObject:letterDelay];
			  break;
		  case '0':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case '1':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case '2':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case '3':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case '4':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case '5':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case '6':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case '7':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case '8':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case '9':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'A':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'B':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'C':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'D':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'E':
			  [tones addObject:dit];
			  break;
		  case 'F':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'G':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'H':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'I':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'J':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'K':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'L':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'M':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'N':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'O':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'P':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'Q':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'R':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'S':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
		  case 'T':
			  [tones addObject:dah];
			  break;
		  case 'U':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'V':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'W':
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'X':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'Y':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  break;
		  case 'Z':
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dah];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  [tones addObject:toneDelay];
			  [tones addObject:dit];
			  break;
	  }
	  [tones addObject:letterDelay];
  }
  return;

}

-(NSString *) encode:(NSString *)plainText {
	for (int i = 0; i < [plainText length]; i++) {
		NSString *currentCharacter = [plainText characterAtIndex:i];
		
		
	}
	
}
@end
